//
//  DTChoosePersonListShowView.m
//  ditelMaintain
//
//  Created by 葛悦彣 on 2023/4/7.
//

#import "DTChoosePersonListShowView.h"
#import "UIScrollView+EmptyDataSet.h"

#define viewH (SCREEN_HEIGHT - kwt(150) - KTop)

@interface DTChoosePersonListShowView()
@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,strong) DTChoosePersonListScrollView * scrollview;
@property (nonatomic ,strong) NSArray<getPondTissueListModel *> * modelArray;
@property (nonatomic ,strong) getPondTissueListModel * model;

@property (nonatomic ,strong) UITextField * ssfield;
@property (nonatomic ,strong) UILabel * rsLab;
@property (nonatomic ,strong) UIView * sssxview;
@property (nonatomic ,strong) void(^block)( getPondTissueListModel *pondModel);
@property (nonatomic ,strong) void(^czblock)(void);
///第一个数据
@property (nonatomic ,strong) getPondTissueListModel * firstmodel;

@end
@implementation DTChoosePersonListShowView
+ (instancetype)showViewWithArray:(NSArray <getPondTissueListModel *>*) Array andBlock:(void(^)(getPondTissueListModel *pondModel))block andCZBlock:(void(^)(void))czblock{
    DTChoosePersonListShowView *  view = [DTChoosePersonListShowView new];
    view.Array = Array;
    for (getPondTissueListModel * model in Array) {
        model.isfirst = YES;
    }
    view.block = block;
    view.czblock = czblock;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    [view newUI];
    return view;
}
+ (instancetype)showViewWithArray:(NSArray <getPondTissueListModel *>* )Array andBlock:(void(^)(getPondTissueListModel * pondModel))block{
    DTChoosePersonListShowView *  view = [DTChoosePersonListShowView new];
    view.Array = Array;
    for (getPondTissueListModel * model in Array) {
        model.isfirst = YES;
    }
    view.block = block;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    [view newUI];
    return view;
}
+ (instancetype)showView{
    DTChoosePersonListShowView *  view = [DTChoosePersonListShowView new];
    
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    
    [view newUI];
    return view;
}
- (void)newUI{
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = UIColor.whiteColor;
    makeView.frame = CGRectMake(0 ,SCREEN_HEIGHT ,SCREEN_WIDTH, viewH );
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft
     |UIRectCornerTopRight andSize:CGRectMake(0, 0, SCREEN_WIDTH, viewH)];
    //    self.userInteractionEnabled = YES;
    //    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    //    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    
    UIView * topview = [UIView new];
    [makeView addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(50));
    }];
    
    UILabel * temp = [DTKTool labelWithText:@"池塘编组" andFont:kCFont(18) andTextColor:KcolorHex(@"#242729")];
    [topview addSubview:temp];
    [temp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(kwt(15));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [topview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(26));
        make.centerY.equalTo(temp);
    }];
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DEE0E2");
    [topview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.height.offset(0.5);
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
    }];
  


    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(80) + KSafeAreaBottomHeight);
    }];
    
    
    UIButton * qxbtn = UIButton.newButton(0).addNormalText(@"取消").addNormalColor(KcolorHex(@"#5A6066")).addFont(kCFont(17)).addbackgroundColor(KcolorHex(@"#F0F2F4")).addTarget(self,@selector(dismiss));
    [DTKTool YJ:kwt(4) andView:qxbtn];
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    
    UIButton * qdbtn = UIButton.newButton(0).addNormalText(@"确定").addFont(kCFont(17)).addNormalColor(UIColor.whiteColor).addTarget(self,@selector(qdbtnclick)).addbackgroundColor([UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")]);
    [buttonview addSubview:qdbtn];
    if(self.czblock){
        qxbtn.addNormalText(@"重置").addTarget(self,@selector(czBtnClick));
    }
    [DTKTool YJ:kwt(4) andView:qdbtn];
    [qdbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    MJWeakSelf
    DTChoosePersonListScrollView * scrollview = [DTChoosePersonListScrollView newView];
    scrollview.newUIBlock = ^(getPondTissueListModel * _Nonnull Model) {
        [weakSelf newAllUI:Model];
    };
    self.scrollview = scrollview;
    [makeView addSubview:scrollview];
    [scrollview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(topview.mas_bottom);
        make.bottom.equalTo(buttonview.mas_top);
    }];
    
    getPondTissueListModel * mm = [getPondTissueListModel new];
    mm.children = self.Array;
    mm.seled = YES;
    self.model = mm;
    scrollview.model = mm;

    [self show];
}


///更新显示
- (void)newAllUI:(getPondTissueListModel *)Model{
    [self.model allNoSeled];
    [self.model childrenModelWithModel:Model SetSeled:YES];
    self.scrollview.model = self.model;
}

- (void)qdbtnclick{
    if(self.block){
        if([self.model seledModel] && ![[self.model seledModel].ID isEqualToString:@"1"]){
            self.block(self.model.seledModel);
            [self dismiss];
        } else {
            [self showWarning:@"请选择池塘编组"];
        }
    }
}
- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, (SCREEN_HEIGHT  - viewH), SCREEN_WIDTH ,viewH);
    }];
}
- (void)czBtnClick{
    if(self.czblock){
        self.czblock();
        [self dismiss];
    }
}
- (void)noclick{
}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end

@interface DTChoosePersonListScrollView ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong) NSMutableArray<DTChoosePersonTableView *> * tableArray;
@property (nonatomic ,strong) NSMutableArray<UIColor *> * tableBackColorArray;
@end

@implementation DTChoosePersonListScrollView
- (NSMutableArray<UIColor *> *)tableBackColorArray {
    if(!_tableBackColorArray){
        _tableBackColorArray = [NSMutableArray arrayWithArray:@[KcolorHex(@"#F0F3F9"),KcolorHex(@"#F7FAFF"),KcolorHex(@"#F0F3F9"),KcolorHex(@"#ffffff")]] ;
    }
    return _tableBackColorArray;
}
- (NSMutableArray<DTChoosePersonTableView *> *)tableArray {
    if(!_tableArray){
        _tableArray = [NSMutableArray array];
    }
    return _tableArray;
}
+ (instancetype)newView{
    DTChoosePersonListScrollView * view = [DTChoosePersonListScrollView new];
    view.userInteractionEnabled = YES;
    return view;
}
- (void)setModel:(getPondTissueListModel *)model{
    _model = model;
    [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    [self.tableArray removeAllObjects];
    [self newTableview:model andX:0];
}
- (void)newTableview:(getPondTissueListModel*)model andX:(CGFloat)X{
    DTChoosePersonTableView * tableview = [[DTChoosePersonTableView alloc] initWithFrame:CGRectMake(X, 0, model.childrenMaxcellW, viewH - kwt(130) - KSafeAreaBottomHeight) style:UITableViewStylePlain];
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableview.delegate = self;
    tableview.dataSource = self;
    tableview.modelArray = model.children;
    if(self.tableBackColorArray.count > self.tableArray.count){
        tableview.backgroundColor = self.tableBackColorArray[self.tableArray.count];
    } else {
        tableview.backgroundColor = UIColor.whiteColor;
    }
    
    [self.tableArray addObject:tableview];
    [self addSubview:tableview];
    [tableview reloadData];
    self.contentSize = CGSizeMake(X + model.childrenMaxcellW, 0);
    BOOL a = YES;
    for (getPondTissueListModel * lmodel in model.children) {
        if(lmodel.seled && lmodel.children.count > 0){
            a = NO;
            [self newTableview:lmodel andX:X + model.childrenMaxcellW];
            return;
        }
    }
    if(a){
        if(self.contentSize.width < SCREEN_WIDTH){
            tableview.mj_w = SCREEN_WIDTH - X;
        }
    }
    if(self.contentSize.width > SCREEN_WIDTH){
        self.contentOffset = CGPointMake(self.contentSize.width- SCREEN_WIDTH, 0);
    }
}

- (NSInteger)tableView:(DTChoosePersonTableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return tableView.modelArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return Kwt(57);
}

- (nonnull UITableViewCell *)tableView:(DTChoosePersonTableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    DTChoosePersonListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"DTChoosePersonListTableViewCell"];
    if (cell == nil) {
        cell = [[DTChoosePersonListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DTChoosePersonListTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = tableView.modelArray[indexPath.row];
    return cell;
}


-(void)tableView:(DTChoosePersonTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    for (getPondTissueListModel * m in tableView.modelArray) {
        if(tableView.modelArray[indexPath.row] == m){
            tableView.modelArray[indexPath.row].seled = !tableView.modelArray[indexPath.row].seled;
            if(tableView.modelArray[indexPath.row].seled == NO){
                [tableView.modelArray[indexPath.row] allNoSeled];
            }
//            self.newUIBlock(m);
        } else {
            m.seled = NO;
        }
    }
    [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    [self.tableArray removeAllObjects];
    [self newTableview:self.model andX:0];
    
}
@end

@implementation DTChoosePersonTableView
@end

@interface DTChoosePersonListTableViewCell()

@property (nonatomic ,strong) UILabel * lab;
@property (nonatomic ,strong) UIImageView * seledimg;
@property (nonatomic ,strong) UIView * bmview;
@property (nonatomic ,strong) UIView * lineview;

@end

@implementation DTChoosePersonListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * lineview = [UIView new];
    lineview.backgroundColor = KcolorHex(@"#0967FF");
    [self.contentView addSubview:lineview];
    self.lineview = lineview;
    [lineview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.width.offset(kwt(4));
        make.height.offset(kwt(35));
        make.centerY.offset(0);
    }];
    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kFont(17) andTextColor:KcolorHex(@"#242729")];
    [self.contentView addSubview:lab];
    self.lab = lab;
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.right.offset(kwt(-35));
        make.centerY.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DEE0E2");
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.height.offset(0.5);
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
    }];
    UIView * bmview = [UIView new];
    bmview.backgroundColor = KcolorHex(@"#0F6DFD");
    self.bmview = bmview;
    [self.contentView addSubview:bmview];
    [bmview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(4));
        make.height.offset(kwt(35));
        make.left.centerY.offset(0);
    }];
    
    
    UIImageView * seledimg = kimageView(@"dwxview_details_return_slice");
    self.seledimg = seledimg;
    [self.contentView addSubview:seledimg];
    [seledimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.height.width.offset(kwt(18));
        make.right.offset(kwt(-15));
    }];
}
- (void)setModel:(getPondTissueListModel *)model {
    self.lab.text = model.name;
    self.bmview.hidden = YES;
    self.backgroundColor = UIColor.clearColor;

    self.lineview.hidden = YES;
    self.seledimg.hidden = [model.ID isEqualToString:@"1"];
    if(model.seled){
        if(model.isfirst){
            self.lineview.hidden = NO;
        }
        self.lab.textColor = KcolorHex(@"#0F6DFD");
        self.seledimg.image = [UIImage imageNamed:@"departmentSeled"];
        [DTKTool YJBK:kwt(9) andView:self.seledimg andWidth:0 andColor:KcolorHex(@"#CECECE")];

    } else {
        self.lab.textColor = KcolorHex(@"#242729");
        self.seledimg.image = [UIImage imageNamed:@""];
        [DTKTool YJBK:kwt(9) andView:self.seledimg andWidth:kwt(1) andColor:KcolorHex(@"#CECECE")];
    }
    
}
@end

@interface DTChooseSXPersonListShowView()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,strong) DTChoosePersonListScrollView * scrollview;
@property (nonatomic ,strong) NSArray<getPondTissueListModel *> * modelArray;
@property (nonatomic ,strong) getPondTissueListModel * model;

@property (nonatomic ,strong) UITextField * ssfield;
@property (nonatomic ,strong) UILabel * rsLab;
@property (nonatomic ,strong) UIView * sssxview;
@property (nonatomic ,strong) void(^block)( getPondTissueListModel *pondModel);
@property (nonatomic ,strong) void(^czblock)(void);
///第一个数据
@property (nonatomic ,strong) getPondTissueListModel * firstmodel;
@property (nonatomic ,strong) UITableView * tableview;
@property (nonatomic ,strong) NSArray<SSpondTissueModel *> * ssmodelArray;
@property (nonatomic ,assign) BOOL isSS;
@property (nonatomic ,strong) NSString * ssID;
@property (nonatomic ,strong) UIButton * scBtn;
@property (nonatomic ,strong) UIButton * qxbtn;
@property (nonatomic ,strong) UIButton * qdbtn;

@end
@implementation DTChooseSXPersonListShowView
-(NSArray<SSpondTissueModel *> *)ssmodelArray{
    if(!_ssmodelArray){
        _ssmodelArray = [NSArray array];
    }
    return _ssmodelArray;
}
+ (instancetype)showViewWithArray:(NSArray <getPondTissueListModel *>*) Array andBlock:(void(^)(getPondTissueListModel *pondModel))block andCZBlock:(void(^)(void))czblock{
    DTChooseSXPersonListShowView *  view = [DTChooseSXPersonListShowView new];
    view.Array = Array;
    for (getPondTissueListModel * model in Array) {
        model.isfirst = YES;
    }
    view.block = block;
    view.czblock = czblock;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    [view newUI];
    return view;
}
+ (instancetype)showViewWithArray:(NSArray <getPondTissueListModel *>* )Array andBlock:(void(^)(getPondTissueListModel * pondModel))block{
    DTChooseSXPersonListShowView *  view = [DTChooseSXPersonListShowView new];
    view.Array = Array;
    for (getPondTissueListModel * model in Array) {
        model.isfirst = YES;
    }
    view.block = block;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    [view newUI];
    return view;
}
+ (instancetype)showView{
    DTChooseSXPersonListShowView *  view = [DTChooseSXPersonListShowView new];
    
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    
    [view newUI];
    return view;
}
- (void)newUI{
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = UIColor.whiteColor;
    makeView.frame = CGRectMake(0 ,SCREEN_HEIGHT ,SCREEN_WIDTH, viewH );
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft
     |UIRectCornerTopRight andSize:CGRectMake(0, 0, SCREEN_WIDTH, viewH)];
    //    self.userInteractionEnabled = YES;
    //    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    //    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    MJWeakSelf
    UIView * topview = [UIView new];
    topview.backgroundColor = KcolorHex(@"#F3F6F9");
    [makeView addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(115));
    }];
    
    UIView * toptopview = [UIView new];
    [topview addSubview:toptopview];
    [toptopview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(50));
    }];
    UILabel * temp = [DTKTool labelWithText:@"池塘编组" andFont:kCFont(18) andTextColor:KcolorHex(@"#242729")];
    [toptopview addSubview:temp];
    [temp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(kwt(15));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [toptopview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(26));
        make.centerY.equalTo(temp);
    }];
  
    UIView * topbuttomview = [UIView new];
    topbuttomview.backgroundColor = UIColor.whiteColor;
    [topview addSubview:topbuttomview];
    [topbuttomview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.equalTo(toptopview.mas_bottom);
    }];
    UIView * btnview = [UIView new];
    btnview.addClickBlock(^{
        [weakSelf openSSview];
    });
    [DTKTool YJBK:kwt(5) andView:btnview andWidth:1 andColor:KcolorHex(@"#D4D5DA")];
    [topbuttomview addSubview:btnview];
    [btnview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(11));
        make.height.offset(kwt(40));
    }];
    
    UIImageView * btnviewimg = kimageView(@"program_search");
    [btnview addSubview:btnviewimg];
    [btnviewimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.centerY.offset(0);
        make.height.width.offset(kwt(16));
    }];
    
    UILabel * btnviewlab = [DTKTool labelWithText:@"请搜索" andFont:kFont(16) andTextColor:KcolorHex(@"#89908D")];
    [btnview addSubview:btnviewlab];
    [btnviewlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(40));
        make.centerY.offset(0);
    }];
    
    UIView * btnline = [UIView new];
    btnline.backgroundColor = KcolorHex(@"#EAEBED");
    [btnview addSubview:btnline];
    [btnline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(280));
        make.centerY.offset(0);
        make.width.offset(0.5);
        make.height.offset(kwt(28));
    }];
    
    UILabel * btnviewsslab = [DTKTool labelWithText:@"搜索" andFont:kCFont(16) andTextColor:KcolorHex(@"#0063FC")];
    [btnview addSubview:btnviewsslab];
    [btnviewsslab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-16));
        make.centerY.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#EFEFEF");
    [topbuttomview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.offset(0);
        make.height.offset(2);
    }];

    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(80) + KSafeAreaBottomHeight);
    }];
    
    
    UIButton * qxbtn = UIButton.newButton(0).addNormalText(@"取消").addNormalColor(KcolorHex(@"#5A6066")).addFont(kCFont(17)).addbackgroundColor(KcolorHex(@"#F0F2F4")).addTarget(self,@selector(dismiss));
    [DTKTool YJ:kwt(4) andView:qxbtn];
    if(self.czblock){
        qxbtn.addNormalText(@"重置").addTarget(self,@selector(czBtnClick));
    }
    self.qxbtn = qxbtn;
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    
    UIButton * qdbtn = UIButton.newButton(0).addNormalText(@"确定").addFont(kCFont(17)).addNormalColor(UIColor.whiteColor).addTarget(self,@selector(qdbtnclick)).addbackgroundColor([UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")]);
    self.qdbtn = qdbtn;
    [buttonview addSubview:qdbtn];
    [DTKTool YJ:kwt(4) andView:qdbtn];
    [qdbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    
    DTChoosePersonListScrollView * scrollview = [DTChoosePersonListScrollView newView];
    scrollview.newUIBlock = ^(getPondTissueListModel * _Nonnull Model) {
        [weakSelf newAllUI:Model];
    };
    self.scrollview = scrollview;
    [makeView addSubview:scrollview];
    [scrollview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(topview.mas_bottom);
        make.bottom.equalTo(buttonview.mas_top);
    }];
    
    getPondTissueListModel * mm = [getPondTissueListModel new];
    mm.children = self.Array;
    mm.seled = YES;
    self.model = mm;
    scrollview.model = mm;
    
    
    UIView * sssxview = [UIView new].addbackgroundColor(UIColor.whiteColor);
    [makeView addSubview:sssxview];
    sssxview.clipsToBounds = YES;
    sssxview.hidden = YES;
    self.sssxview = sssxview;
    [sssxview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.right.offset(0);
        make.bottom.equalTo(scrollview.mas_bottom);
    }];
    
   
    
    UIView * ssview = [UIView new];
    [DTKTool YJBK:kwt(4) andView:ssview andWidth:0.5 andColor:KcolorHex(@"#0F6DFD")];
    [sssxview addSubview:ssview];
    [ssview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(15));
        make.left.offset(kwt(50));
        make.right.offset(kwt(-20));
        make.height.offset(kwt(40));
    }];
    UIView * ssline = [UIView new];
    ssline.backgroundColor = KcolorHex(@"#DEE0E2");
    [sssxview addSubview:ssline];
    [ssline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.height.offset(2);
        make.top.offset(kwt(70) - 2);
    }];
    UIImageView * ssimg = kimageView(@"program_search");
    [ssview addSubview:ssimg];
    [ssimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.width.height.offset(kwt(15));
        make.centerY.offset(0);
    }];
   
    
    UILabel * ssbtnviewsslab = [DTKTool labelWithText:@"搜索" andFont:kCFont(16) andTextColor:KcolorHex(@"#0063FC")];
    ssbtnviewsslab.addClickBlock(^{
        [weakSelf loadNewData];
    });
    ssbtnviewsslab.mas_KLS().mas_KYS();
    [ssview addSubview:ssbtnviewsslab];
    [ssbtnviewsslab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-16));
        make.centerY.offset(0);
    }];
    
    UIView * ssbtnline = [UIView new];
    ssbtnline.backgroundColor = KcolorHex(@"#EAEBED");
    [ssview addSubview:ssbtnline];
    [ssbtnline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(ssbtnviewsslab.mas_left).offset(kwt(-10));
        make.centerY.offset(0);
        make.width.offset(0.5);
        make.height.offset(kwt(28));
    }];
    
    UIButton * scBtn= [UIButton buttonWithType:0];
    scBtn.addTarget(self,@selector(SCbtnClick));
    scBtn.hidden = YES;
    self.scBtn = scBtn;
    scBtn.addimg([UIImage imageNamed:@"search_delete"]);
    [ssview addSubview:scBtn];
    [scBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(ssbtnline.mas_left).offset(kwt(-5));
        make.centerY.offset(0);
        make.width.height.offset(kwt(20));
    }];
    
    UITextField * ssfield = [UITextField new];
    self.ssfield = ssfield;
    ssfield.delegate = self;
    ssfield.placeholder = @"请搜索";
    ssfield.font = kFont(16);
    ssfield.returnKeyType = UIReturnKeySearch;

    [ssview addSubview:ssfield];
    [ssfield mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(38));
        make.top.bottom.offset(0);
        make.right.equalTo(ssbtnline.mas_left).offset(kwt(-30));
    }];
    
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFieldTextDidChangeOneCI:)
                                                name:UITextFieldTextDidChangeNotification
                                              object:ssfield];
    UIImageView * ssimgbtn = kimageView(@"left_black_path");
    ssimgbtn.addClickBlock(^{
        [weakSelf cleanSSview];
    });
    [sssxview addSubview:ssimgbtn];
    [ssimgbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.width.height.offset(kwt(25));
        make.centerY.equalTo(ssview);
    }];
    UITableView * tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, viewH - kwt(70)) style:UITableViewStyleGrouped];
    self.tableview = tableview;
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableview.emptyDataSetSource = self;
    tableview.emptyDataSetDelegate = self;
    tableview.delegate = self;
    tableview.dataSource = self;
    tableview.backgroundColor = UIColor.whiteColor;
    [sssxview addSubview:tableview];
    [tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.offset(kwt(70));
    }];
//    tableview.hidden = YES;
//    
    [ssfield addTarget:self action:@selector(textChange:) forControlEvents:UIControlEventEditingChanged];

    
    [self show];
}

-(void)textChange:(UITextField *)textField{
    self.scBtn.hidden = (textField.text.length == 0);
}

- (void)SCbtnClick{
    
    self.ssfield.text = @"";
    self.ssmodelArray = @[];
    [self.tableview reloadData];
    self.scBtn.hidden =YES;
}

//是否滑动
-(BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
    return NO;
}
- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView {
    if(self.ssfield.text.length < 1){return nil;}
    UIView * noView = [UIView new];
    UIView * NewnoView = [UIView new];
//    NewnoView.backgroundColor = UIColor.whiteColor;
    [noView addSubview:NewnoView];
    [NewnoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_offset(KSCREEN_WIDTH); 
        make.center.offset(0);
        make.height.mas_offset(KSCREEN_HEIGHT);
    }];
    UIImageView * noImage = [UIImageView new];
    [noView addSubview:noImage];
    noImage.image = [UIImage imageNamed:@"no_search"];
    [noImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.centerY.mas_offset(-100);
    }];
    
    UILabel * noTitleLab = [UILabel new];
    [noView addSubview:noTitleLab];
    noTitleLab.text = @"暂无搜索记录\n换个关键词试试~";
    noTitleLab.numberOfLines = 2;
    noTitleLab.font = kFont(16);
    noTitleLab.textColor = [UIColor colorWithHexString:@"#44454C"];
    [noTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(noImage.mas_bottom).offset(30);
        make.centerX.mas_offset(0);
    }];
    
    return noView;
}
- (void)openSSview{
    self.isSS = YES;
    self.sssxview.hidden = NO;
    self.ssfield.text = @"";
    self.scBtn.hidden = YES;
    [self.ssfield becomeFirstResponder];
}
- (void)cleanSSview{
    self.isSS = NO;
    self.sssxview.hidden = YES;
    self.qxbtn.hidden = self.qdbtn.hidden = NO;
}

-(void)textFieldTextDidChangeOneCI:(NSNotification *)notification
{
    UITextField *textfield=[notification object];
    if([textfield markedTextRange] == nil){
        NSLog(@"ssssss %@",textfield.text);
        [self loadNewData];
    }
}
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    
    if ([string isEqualToString:@"\n"] && textField.text.length > 0){
        [self loadNewData];
        [self endEditing:YES];
        return NO;
    }
    return YES;
}

- (void)loadNewData{
    if(self.ssfield.text.length < 1){
        return;
    }
    [self showBusyHUD];
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.ssfield.text forKey:@"param"];
    [SCNetManger PostPondTissueTissueOpFilterListWithDict:dict andCompetionHandlerBlock:^(HTTPArrBase * model) {
        [self hideBusyHUD];
        if(model.code == 200){
            self.ssmodelArray = [NSArray yy_modelArrayWithClass:SSpondTissueModel.class json:model.result];
                
            self.qxbtn.hidden = self.qdbtn.hidden = (self.ssmodelArray.count < 1);
            
            [self.tableview reloadData];
        } else {
            [self showWarning:model.message];
        }
    }];
}


///更新显示
- (void)newAllUI:(getPondTissueListModel *)Model{
    [self.model allNoSeled];
    [self.model childrenModelWithModel:Model SetSeled:YES];
    self.scrollview.model = self.model;
}

- (void)qdbtnclick{
    if(self.block){
        if(self.isSS){
            for (SSpondTissueModel * m in self.ssmodelArray) {
                if(m.isSeled){
                    getPondTissueListModel * model = [getPondTissueListModel new];
                    model.ID = m.ID;
                    if(m.fname.length > 0){
                        model.TJname = [NSString stringWithFormat:@"%@-%@",m.ffname,m.fname];
                    } else{
                        model.TJname = m.ffname;
                    }
                    self.block(model);
                    [self dismiss];

                    return;
                }
            }
            [self showWarning:@"请选择"];
        } else {
            if([self.model seledModel] && ![[self.model seledModel].ID isEqualToString:@"1"]){
                self.block(self.model.seledModel);
                [self dismiss];
            } else {
                [self showWarning:@"请选择池塘编组"];
            }
        }
    }
}
- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, (SCREEN_HEIGHT  - viewH), SCREEN_WIDTH ,viewH);
    }];
}

- (void)noclick{
}
- (void)czBtnClick{
    if(self.czblock){
        self.czblock();
        [self dismiss];
    }
}
- (void)dismiss{
    
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * view =   [UIView new];
    view.backgroundColor = UIColor.whiteColor;
    view.clipsToBounds = YES;
    UILabel * lab = [DTKTool labelWithText:@"搜索结果" andFont:kFont(18) andTextColor:KcolorHex(@"#8D97A1")];
    [view addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(20));
        make.centerY.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DEE0E2");
    [view addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(0.5);
    }];
    return view;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(self.ssmodelArray.count > 0){
        return kwt(50);
    }
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.ssmodelArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kwt(77);
}

- (nonnull UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    DTChooseSXPersonListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"DTChooseSXPersonListTableViewCell"];
    if (cell == nil) {
        cell = [[DTChooseSXPersonListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DTChooseSXPersonListTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = self.ssmodelArray[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(self.ssmodelArray[indexPath.row].isSeled){
        for (SSpondTissueModel * model in self.ssmodelArray) {
            model.isSeled = NO;
        }
    } else {
        self.ssmodelArray[indexPath.row].isSeled = !self.ssmodelArray[indexPath.row].isSeled;
    }
    
    
    [self.tableview reloadData];
}
@end
@implementation SSpondTissueModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
    };
}
@end
@interface DTChooseSXPersonListTableViewCell()
@property (nonatomic ,strong) UILabel * ffname;
@property (nonatomic ,strong) UILabel * name;

@end
@implementation DTChooseSXPersonListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#242729")];
    self.name = name;
    [self.contentView addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(20));
        make.top.offset(kwt(15));
    }];
    
    
    UILabel * ffname = [DTKTool labelWithText:@"" andFont:kFont(15) andTextColor:KcolorHex(@"#8D97A1")];
    self.ffname = ffname;
    [self.contentView addSubview:ffname];
    [ffname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-20));
        make.left.offset(kwt(20));
        make.top.offset(kwt(43));
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DEE0E2");
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(0.5);
    }];
    
}
- (void)setModel:(SSpondTissueModel *)model{
    _model = model;
    self.name.text = model.ffname;
    if(model.fname.length > 0){
        if(model.name.length > 0){
            self.ffname.text = [NSString stringWithFormat:@"%@ > %@",model.fname,model.name];
        } else {
            self.ffname.text = model.fname;
        }
        
    } else{
        self.ffname.text = @"";
    }
    if(model.isSeled){
        self.name.textColor = KcolorHex(@"#0F6DFD");
        self.ffname.textColor = KcolorHex(@"#0F6DFD");
    } else {
        self.name.textColor = KcolorHex(@"#242729");
        self.ffname.textColor = KcolorHex(@"#8D97A1");

    }
}
@end

@interface DTChooseKindListShowView()
@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,strong) DTChoosePersonListScrollView * scrollview;
@property (nonatomic ,strong) NSArray<getPondTissueListModel *> * modelArray;
@property (nonatomic ,strong) getPondTissueListModel * model;

@property (nonatomic ,strong) UITextField * ssfield;
@property (nonatomic ,strong) UILabel * rsLab;
@property (nonatomic ,strong) UIView * sssxview;
@property (nonatomic ,strong) void(^block)( getPondTissueListModel *pondModel);
@property (nonatomic ,strong) void(^czblock)(void);
///第一个数据
@property (nonatomic ,strong) YTStashLeftModel * firstmodel;

@end
@implementation DTChooseKindListShowView
+ (instancetype)showViewWithArray:(NSArray <getPondTissueListModel *>*) Array andBlock:(void(^)(getPondTissueListModel *pondModel))block andCZBlock:(void(^)(void))czblock{
    DTChooseKindListShowView *  view = [DTChooseKindListShowView new];
    view.Array = Array;
//    for (getPondTissueListModel * model in Array) {
//        model.isfirst = YES;
//    }
    view.block = block;
    view.czblock = czblock;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    [view newUI];
    return view;
}
+ (instancetype)showView{
    DTChooseKindListShowView *  view = [DTChooseKindListShowView new];
    
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [[DTKTool getCurrentVC].view addSubview:view];
    
    [view newUI];
    return view;
}
- (void)newUI{
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = UIColor.whiteColor;
    makeView.frame = CGRectMake(0 ,SCREEN_HEIGHT ,SCREEN_WIDTH, viewH );
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft
     |UIRectCornerTopRight andSize:CGRectMake(0, 0, SCREEN_WIDTH, viewH)];
    //    self.userInteractionEnabled = YES;
    //    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    //    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    
    UIView * topview = [UIView new];
    [makeView addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(50));
    }];
    
    UILabel * temp = [DTKTool labelWithText:@"物品品类" andFont:kCFont(18) andTextColor:KcolorHex(@"#242729")];
    [topview addSubview:temp];
    [temp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(kwt(15));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [topview addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(26));
        make.centerY.equalTo(temp);
    }];
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DEE0E2");
    [topview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.height.offset(0.5);
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
    }];
  


    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(80) + KSafeAreaBottomHeight);
    }];
    
    
    UIButton * qxbtn = UIButton.newButton(0).addNormalText(@"重置").addNormalColor(KcolorHex(@"#5A6066")).addFont(kCFont(17)).addbackgroundColor(KcolorHex(@"#F0F2F4")).addTarget(self,@selector(czBtnClick));
    [DTKTool YJ:kwt(4) andView:qxbtn];
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    
    UIButton * qdbtn = UIButton.newButton(0).addNormalText(@"确定").addFont(kCFont(17)).addNormalColor(UIColor.whiteColor).addTarget(self,@selector(qdbtnclick)).addbackgroundColor([UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")]);
    [buttonview addSubview:qdbtn];
    if(self.czblock){
        qxbtn.addNormalText(@"重置").addTarget(self,@selector(czBtnClick));
    }
    [DTKTool YJ:kwt(4) andView:qdbtn];
    [qdbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-17));
        make.top.offset(kwt(17));
        make.width.offset(kwt(160));
        make.height.offset(kwt(44));
    }];
    MJWeakSelf
    DTChoosePersonListScrollView * scrollview = [DTChoosePersonListScrollView newView];
    scrollview.newUIBlock = ^(getPondTissueListModel * _Nonnull Model) {
        [weakSelf newAllUI:Model];
    };
    self.scrollview = scrollview;
    [makeView addSubview:scrollview];
    [scrollview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(topview.mas_bottom);
        make.bottom.equalTo(buttonview.mas_top);
    }];
    
    getPondTissueListModel * mm = [getPondTissueListModel new];
    mm.children = self.Array;
    mm.seled = YES;
    self.model = mm;
    scrollview.model = mm;

    [self show];
}


///更新显示
- (void)newAllUI:(getPondTissueListModel *)Model{
    [self.model allNoSeled];
    [self.model childrenModelWithModel:Model SetSeled:YES];
    self.scrollview.model = self.model;
}

- (void)qdbtnclick{
    if(self.block){
        if([self.model seledModel] && ![[self.model seledModel].ID isEqualToString:@"1"]){
            self.block(self.model.seledModel);
            [self dismiss];
        } else {
            [self showWarning:@"请选择物品品类"];
        }
    }
}

- (void)show{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, (SCREEN_HEIGHT  - viewH), SCREEN_WIDTH ,viewH);
    }];
}
- (void)czBtnClick{
    if(self.czblock){
        self.czblock();
        [self dismiss];
    }
}
- (void)noclick{
}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
